<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>

<div id = "body">

<h1><?_l('qoute')?></h1>

<div class = "page">
<?
  $count = $db->countOfAll('hs_qoute');
  $start = setpage($count);
?>
</div>

<?php
    
  $sql = "SELECT * FROM hs_qoute ORDER BY q_dateadd DESC LIMIT $start,".PAGE;
  //echo $sql;
  $rss = $db->query($sql);
  if($db->numRows()){
    $check = TRUE;
    while ($line = $db->fetchNextObject($rss)){
      if($line->q_status==0){
        $newQoute = '<img src="../images/new.gif" alt="new" />';
        $viewedBt = '<input type = "submit" value = "Viewed" class = "btn qouteChangeStat" id="'.$line->q_id.'">';
      }else{
        $newQoute = '';
        $viewedBt = '<input type = "submit" value = "Unviewed" class = "btn qouteChangeStat" id="'.$line->q_id.'">';
      }
      $date = date('d/m/Y',$line->q_dateadd);
      $memberInfo = $db->queryUniqueObject('SELECT * FROM hs_member WHERE m_id='.$line->m_id);
      $qouteList .=<<<qouteList
        <tr>
          <td><a class="aColorBox" href="qoute_detail.php?q_id={$line->q_id}">{$date} {$newQoute}</a></td>
          <td><a class="aColorBox" href="qoute_detail.php?q_id={$line->q_id}">{$memberInfo->m_name} {$memberInfo->m_lastname}</a></td>
          <td>{$viewedBt}</td>
        </tr>
qouteList;
    }
  }else{
    $check = FALSE;
  }
?>

<div class = "clear"></div>

<?php if($check): ?>
      <table class ="list">
        <tr>
          <th scope="col" width = "120"><?php _l('Date'); ?></th>
          <th scope="col" width = "300"><?php _l('Member'); ?></th>
          <th scope="col" width = "70"></th>
        </tr>
        <?php echo $qouteList; ?>
      </table>
<?php else: ?>

<div id="coupon-detail">
  <?php _l('no data'); ?>
</div>

<?php endif; ?>


</div>

<style>

</style>

<? include "../footer.php" ?>
<script>
  $(document).ready(function(){
    $(".aColorBox").fancybox();
    
    $('.qouteChangeStat').live('click',function(){
      $.post('qoute-change-stat.php',{ q_id : $(this).attr('id') },function(data){
        if(data.status=='success'){
          window.location.reload();
        }else{
          alert('sss');
        }
      },'json');
    });
  });
</script>